<template>
  <el-container class="full-container">
    <!--侧栏菜单-->
    <el-aside width="200px">
      <el-menu>
        <el-submenu index="1">
          <template slot="title"><i class="el-icon-menu"></i>系统管理</template>
          <el-menu-item index="1-1">
            <router-link to="/admin/user" tag="span">用户管理</router-link>
          </el-menu-item>
          <el-menu-item index="1-2">
            <router-link to="/admin/role" tag="span">角色管理</router-link>
          </el-menu-item>
        </el-submenu>
      </el-menu>
    </el-aside>
    <!--主内容区域---分为header与main两部分-->
    <el-container>
      <el-header>
        当前用户: {{ username }}
        <el-button type="primary" size="mini" @click="logout">退出登录</el-button>
      </el-header>
      <el-main>
        <router-view></router-view>
      </el-main>
    </el-container>

  </el-container>
</template>

<script>
import {mapState} from "vuex";

export default {
  name: "AdminView",
  data(){
    return {
    }
  },
  methods:{
    logout(){
      // // 退出登录，清空用户名
      this.$store.commit('setUsername', '');
      // 跳转到登录页
      this.$router.push('/');
    }
  },
  computed: {
    ...mapState(['username']),
  }
}
</script>

<style scoped>
  /* 修改容器高度以铺满全屏 */
.full-container {
  height: 100vh;
}

  .el-header {
    background-color: #3c8dbc;
    color: #333;
    text-align: right;
    line-height: 60px;
  }

  .el-aside {
  background-color: #2f4050;
  color: #bfcbd9;
  line-height: 200px;
}

.el-main {
  text-align: center;
  padding: 0;
  margin: 0;
  background-color: #E9EEF3;
  color: #2f4050;
}
</style>